const App = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    show5: false,
    show1: false,
    show2: false,
    show3: false,
    show4: false,
    show6:false,
    show7:false
  },
        /**
   * 获取分销商中心数据
   */
  getDealerCenter() {
    let _this = this;
    App._get('user.dealer/center', {}, function(result) {
      let data = result.data;
      data.isData = true;
      // // 设置当前页面标题
      // wx.setNavigationBarTitle({
      //   title: data.words.index.title.value
      // });
      _this.setData(data);
    });
  },
  handleOpen(e) {
    let index = e.currentTarget.dataset.index * 1
    if (index === 1) {
      this.setData({
        show1: !this.data.show1
      })
    } else if (index === 2) {
      this.setData({
        show2: !this.data.show2
      })
    } else if (index === 3) {
      this.setData({
        show3: !this.data.show3
      })
    } else if (index === 4) {
      this.setData({
        show4: !this.data.show4
      })
    } else if (index === 5) {
      this.setData({
        show5: !this.data.show5
      })
    } else if (index === 6) {
      this.setData({
        show6: !this.data.show6
      })
    }
     else {
      this.setData({
        show7: !this.data.show7
      })
    }
  },
  fetchremark() {
    App._post_form("info/getMoneyRemark", {}, (res) => {
      if (res.code == 1) {
        this.setData(res.data)
      }
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
   
    this.fetchremark()
    this.fetchAdver()
  },
  // 获取广告
  fetchAdver() {
    App._post_form('info/getAdverts', {
      type: 1
    }, (res) => {
      console.log(res.data)
      this.setData({
        adverts: res.data.adverts
      })
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getDealerCenter()
    let _this = this;
    // 获取我的钱包
    _this.getUserDetail();
  },

  /**
   * 获取我的钱包
   */
  getUserDetail: function () {
    let _this = this;
    App._get('user.wallet/index', {}, function (result) {
      _this.setData(result.data);
    });
  },

  /**
   * 跳转充值页面
   */
  onTargetRecharge(e) {
    wx.navigateTo({
      url: '../recharge/index'
    })
  },
  /**
   * 跳转提现页面
   */
  onTargettixian(e) {
    wx.navigateTo({
      url: '../../user/money/indexs'
    })
  },

  /**
   * 跳转充值记录页面
   */
  onTargetRechargeOrder(e) {
    wx.navigateTo({
      url: '../recharge/order/index'
    })
  },

  /**
   * 跳转账单详情页面
   */
  onTargetBalanceLog(e) {
    wx.navigateTo({
      url: '../wallet/balance/log'
    })
  },

})